﻿using System;
using XCI.Core;
using XCI.Helper;
using XCI.Windows;

namespace XCI.Forms
{
    public partial class WebApiClientConfigUserControl : BaseUserControl
    {
        private WebApiConfig config;
        public WebApiClientConfigUserControl()
        {
            InitializeComponent();
        }
        
        public WebApiConfig Config
        {
            get => config;
            set
            {
                if (WinFormHelper.IsDesignMode()) return;
                config = value ?? new WebApiConfig();
                bindingSource.DataSource = config;
            }
        }

        private async void BtnTest_Click(object sender, EventArgs e)
        {
            await Loading.ShowAsync(() => WinFormHelper.WebApiClientTest(Config));
        }
    }
}
